﻿@{
    ViewBag.Title = "活动管理";
    Layout = "~/Views/Shared/_Index.cshtml";
}
<script src="~/Content/js/common.js"></script>
<script src="~/Content/js/datepicker/WdatePicker.js"></script>
<script>
    $(function () {
        gridList();
    })

    function gridList() {
        var $gridList = $("#gridList");
        $gridList.dataGrid({
            url: "/Activity/GetGridJson",
            height: $(window).height() - 128,
            colModel: [
                { label: '主键', name: 'ID', hidden: true },
                { label: '标题', name: 'Title', width: 300,  align: 'left' },
                { label: '描述', name: 'Description', width: 500, align: 'left' },
                { label: '添加者', name: 'AddPerson', width: 100, align: 'left' },
                {
                    label: '添加时间', name: 'AddTime', width: 100, align: 'left',
                    formatter: function (cellvalue, options, rowObject) {
                        return (new Date(rowObject.AddTime).format("yyyy-MM-dd hh:mm:ss"));
                    }
                }
            ],
            pager: "#gridPager",
            sortname: 'AddTime desc',
            viewrecords: true
        });
        $("#btn_search").click(function () {
            $gridList.jqGrid('setGridParam', {
                postData: {
                    Title: $("#txt_Title").val() ,
                    StartTime: $.trim($("#StartTime").val()),
                    EndTime: $.trim($("#EndTime").val())
                },
            }).trigger('reloadGrid');
        });
    }
    function btn_delete() {
        $.deleteForm({
            url: "/Activity/DeleteForm",
            param: { keyValue: $("#gridList").jqGridRowValue().ID },
            prompt: "注：您确定要删除该项数据吗？",
            success: function () {
                $.currentWindow().$("#gridList").trigger("reloadGrid");
            }
        })
    }
    function btn_details() {
        var keyValue = $("#gridList").jqGridRowValue().ID;
        $.modalOpen({
            id: "Details",
            title: "查看活动信息",
            url: "/Activity/Details?keyValue=" + keyValue,
            width: "1030px",
            height: "650px",
            btn: null,
        });
    }
    function btn_edit() {
        var keyValue = $("#gridList").jqGridRowValue().ID;
        $.modalOpen({
            id: "Edit",
            title: "编辑活动信息",
            url: "/Activity/Edit?keyValue=" + keyValue,
            width: "1030px",
            height: "650px",
            callBack: function (iframeId) {
                top.frames[iframeId].submitForm();
            }
        });
    }

    function btn_add() {
        $.modalOpen({
            id: "Edit",
            title: "编辑活动信息",
            url: "/Activity/Edit",
            width: "1030px",
            height: "650px",
            callBack: function (iframeId) {
                top.frames[iframeId].submitForm();
            }
        });
    }
</script>

<div class="topPanel">
    <div class="toolbar">
        <div class="btn-group">
            <a class="btn btn-primary" onclick="$.reload()"><span class="glyphicon glyphicon-refresh"></span></a>
        </div>
        <div class="btn-group">
            <a id="NF-add" authorize="yes" class="btn btn-primary dropdown-text" onclick="btn_add()"><i class="fa fa-plus"></i>新增活动信息</a>
        </div>
        <div class="operate">
            <ul class="nav nav-pills">
                <li class="first">已选中<span>1</span>项</li>
                <li><a id="NF-edit" authorize="yes" onclick="btn_edit()"><i class="fa fa-pencil-square-o"></i>修改活动信息</a></li>
                <li><a id="NF-delete" authorize="yes" onclick="btn_delete()"><i class="fa fa-trash-o"></i>删除活动信息</a></li>
                <li><a id="NF-Details" authorize="yes" onclick="btn_details()"><i class="fa fa-search-plus"></i>查看</a></li>
                <li class="split"></li>
            </ul>
            <a href="javascript:;" class="close"></a>
        </div>
        <script>$('.toolbar').authorizeButton()</script>
    </div>
    <div class="search">
        <table>
            <tr>
                <td>
                    <div class="input-group">
                        <input id="txt_Title" type="text" class="form-control" placeholder="标题名称" style="width: 200px;margin-left: 10px;" maxlength="25">
                        <input id="StartTime" name="SetUpTime" type="text" class="input-wdatepicker" style="width: 150px;margin-left: 10px;height:29px;" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd' })" placeholder="开始时间">
                        <input id="EndTime" name="SetUpTime" type="text" class="input-wdatepicker" style="width: 150px;margin-left: 10px;height:29px;" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd' })" placeholder="结束时间">
                        <span class="input-group-btn">
                            <button id="btn_search" type="button" class="btn  btn-primary"><i class="fa fa-search"></i></button>
                        </span>
                    </div>
                </td>
            </tr>
        </table>
    </div>
</div>
<div class="gridPanel">
    <table id="gridList"></table>
    <div id="gridPager"></div>
</div>
